package com.example.shop.controller;

import com.example.shop.entity.Articlecategory;
import com.example.shop.service.ArticlecategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName ArticlecategoryController
 * @Description TODO
 * @Author 吴
 * @Date 2025/3/26 10:27
 */
@RestController
@RequestMapping("articlecategory")
public class ArticlecategoryController {
    @Autowired
    private ArticlecategoryService articlecategoryService;

    /**
     * 通过ID查询单条数据
     *
     * @param articlecategoryid 主键
     * @return 单条数据
     */
    @GetMapping("{articlecategoryid}")
    public Articlecategory queryById(@PathVariable("articlecategoryid") Integer articlecategoryid) {
        return articlecategoryService.queryById(articlecategoryid);
    }

    /**
     * 新增数据
     *
     * @param articlecategory 实例对象
     * @return 新增后的实例对象
     */
    @PostMapping
    public Articlecategory insert(@RequestBody Articlecategory articlecategory) {
        return articlecategoryService.insert(articlecategory);
    }

    /**
     * 修改数据
     *
     * @param articlecategory 实例对象
     * @return 修改后的实例对象
     */
    @PutMapping
    public Articlecategory update(@RequestBody Articlecategory articlecategory) {
        return articlecategoryService.update(articlecategory);
    }

    /**
     * 通过主键删除数据
     *
     * @param articlecategoryid 主键
     * @return 是否成功
     */
    @DeleteMapping("{articlecategoryid}")
    public boolean deleteById(@PathVariable("articlecategoryid") Integer articlecategoryid) {
        return articlecategoryService.deleteById(articlecategoryid);
    }

    /**
     * 查询所有数据
     */
//    @GetMapping
//    public List<Articlecategory> queryAll() {
//        throw new UnsupportedOperationException("This operation is not yet supported.");
//    }
}
